package com.fitns.user.mapper.baseConfig;

import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.fitns.user.model.baseConfig.TbStaffTrailHis;

import java.util.List;
import javax.annotation.Generated;

import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.render.RenderingStrategy;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSL;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;

@Mapper
public interface TbStaffTrailHisMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="record.id", before=false, resultType=Long.class)
    int insert(InsertStatementProvider<TbStaffTrailHis> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TbStaffTrailHisResult")
    TbStaffTrailHis selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TbStaffTrailHisResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="road_id", property="roadId", jdbcType=JdbcType.BIGINT),
        @Result(column="organ_id", property="organId", jdbcType=JdbcType.BIGINT),
        @Result(column="status", property="status", jdbcType=JdbcType.VARCHAR),
        @Result(column="work_long", property="workLong", jdbcType=JdbcType.REAL),
        @Result(column="frequency", property="frequency", jdbcType=JdbcType.INTEGER),
        @Result(column="input_time", property="inputTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR)
    })
    List<TbStaffTrailHis> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
        return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
                .from(TbStaffTrailHisDynamicSqlSupport.tbStaffTrailHis);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
        return DeleteDSL.deleteFromWithMapper(this::delete, TbStaffTrailHisDynamicSqlSupport.tbStaffTrailHis);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(Long id_) {
        return DeleteDSL.deleteFromWithMapper(this::delete, TbStaffTrailHisDynamicSqlSupport.tbStaffTrailHis)
                .where(TbStaffTrailHisDynamicSqlSupport.id, isEqualTo(id_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(TbStaffTrailHis record) {
        return insert(SqlBuilder.insert(record)
                .into(TbStaffTrailHisDynamicSqlSupport.tbStaffTrailHis)
                .map(TbStaffTrailHisDynamicSqlSupport.name).toProperty("name")
                .map(TbStaffTrailHisDynamicSqlSupport.phone).toProperty("phone")
                .map(TbStaffTrailHisDynamicSqlSupport.roadId).toProperty("roadId")
                .map(TbStaffTrailHisDynamicSqlSupport.organId).toProperty("organId")
                .map(TbStaffTrailHisDynamicSqlSupport.status).toProperty("status")
                .map(TbStaffTrailHisDynamicSqlSupport.workLong).toProperty("workLong")
                .map(TbStaffTrailHisDynamicSqlSupport.frequency).toProperty("frequency")
                .map(TbStaffTrailHisDynamicSqlSupport.inputTime).toProperty("inputTime")
                .map(TbStaffTrailHisDynamicSqlSupport.remark).toProperty("remark")
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(TbStaffTrailHis record) {
        return insert(SqlBuilder.insert(record)
                .into(TbStaffTrailHisDynamicSqlSupport.tbStaffTrailHis)
                .map(TbStaffTrailHisDynamicSqlSupport.name).toPropertyWhenPresent("name", record::getName)
                .map(TbStaffTrailHisDynamicSqlSupport.phone).toPropertyWhenPresent("phone", record::getPhone)
                .map(TbStaffTrailHisDynamicSqlSupport.roadId).toPropertyWhenPresent("roadId", record::getRoadId)
                .map(TbStaffTrailHisDynamicSqlSupport.organId).toPropertyWhenPresent("organId", record::getOrganId)
                .map(TbStaffTrailHisDynamicSqlSupport.status).toPropertyWhenPresent("status", record::getStatus)
                .map(TbStaffTrailHisDynamicSqlSupport.workLong).toPropertyWhenPresent("workLong", record::getWorkLong)
                .map(TbStaffTrailHisDynamicSqlSupport.frequency).toPropertyWhenPresent("frequency", record::getFrequency)
                .map(TbStaffTrailHisDynamicSqlSupport.inputTime).toPropertyWhenPresent("inputTime", record::getInputTime)
                .map(TbStaffTrailHisDynamicSqlSupport.remark).toPropertyWhenPresent("remark", record::getRemark)
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<TbStaffTrailHis>>> selectByExample() {
        return SelectDSL.selectWithMapper(this::selectMany, TbStaffTrailHisDynamicSqlSupport.id, TbStaffTrailHisDynamicSqlSupport.name, TbStaffTrailHisDynamicSqlSupport.phone, TbStaffTrailHisDynamicSqlSupport.roadId, TbStaffTrailHisDynamicSqlSupport.organId, TbStaffTrailHisDynamicSqlSupport.status, TbStaffTrailHisDynamicSqlSupport.workLong, TbStaffTrailHisDynamicSqlSupport.frequency, TbStaffTrailHisDynamicSqlSupport.inputTime, TbStaffTrailHisDynamicSqlSupport.remark)
                .from(TbStaffTrailHisDynamicSqlSupport.tbStaffTrailHis);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<TbStaffTrailHis>>> selectDistinctByExample() {
        return SelectDSL.selectDistinctWithMapper(this::selectMany, TbStaffTrailHisDynamicSqlSupport.id, TbStaffTrailHisDynamicSqlSupport.name, TbStaffTrailHisDynamicSqlSupport.phone, TbStaffTrailHisDynamicSqlSupport.roadId, TbStaffTrailHisDynamicSqlSupport.organId, TbStaffTrailHisDynamicSqlSupport.status, TbStaffTrailHisDynamicSqlSupport.workLong, TbStaffTrailHisDynamicSqlSupport.frequency, TbStaffTrailHisDynamicSqlSupport.inputTime, TbStaffTrailHisDynamicSqlSupport.remark)
                .from(TbStaffTrailHisDynamicSqlSupport.tbStaffTrailHis);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default TbStaffTrailHis selectByPrimaryKey(Long id_) {
        return SelectDSL.selectWithMapper(this::selectOne, TbStaffTrailHisDynamicSqlSupport.id, TbStaffTrailHisDynamicSqlSupport.name, TbStaffTrailHisDynamicSqlSupport.phone, TbStaffTrailHisDynamicSqlSupport.roadId, TbStaffTrailHisDynamicSqlSupport.organId, TbStaffTrailHisDynamicSqlSupport.status, TbStaffTrailHisDynamicSqlSupport.workLong, TbStaffTrailHisDynamicSqlSupport.frequency, TbStaffTrailHisDynamicSqlSupport.inputTime, TbStaffTrailHisDynamicSqlSupport.remark)
                .from(TbStaffTrailHisDynamicSqlSupport.tbStaffTrailHis)
                .where(TbStaffTrailHisDynamicSqlSupport.id, isEqualTo(id_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(TbStaffTrailHis record) {
        return UpdateDSL.updateWithMapper(this::update, TbStaffTrailHisDynamicSqlSupport.tbStaffTrailHis)
                .set(TbStaffTrailHisDynamicSqlSupport.name).equalTo(record::getName)
                .set(TbStaffTrailHisDynamicSqlSupport.phone).equalTo(record::getPhone)
                .set(TbStaffTrailHisDynamicSqlSupport.roadId).equalTo(record::getRoadId)
                .set(TbStaffTrailHisDynamicSqlSupport.organId).equalTo(record::getOrganId)
                .set(TbStaffTrailHisDynamicSqlSupport.status).equalTo(record::getStatus)
                .set(TbStaffTrailHisDynamicSqlSupport.workLong).equalTo(record::getWorkLong)
                .set(TbStaffTrailHisDynamicSqlSupport.frequency).equalTo(record::getFrequency)
                .set(TbStaffTrailHisDynamicSqlSupport.inputTime).equalTo(record::getInputTime)
                .set(TbStaffTrailHisDynamicSqlSupport.remark).equalTo(record::getRemark);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(TbStaffTrailHis record) {
        return UpdateDSL.updateWithMapper(this::update, TbStaffTrailHisDynamicSqlSupport.tbStaffTrailHis)
                .set(TbStaffTrailHisDynamicSqlSupport.name).equalToWhenPresent(record::getName)
                .set(TbStaffTrailHisDynamicSqlSupport.phone).equalToWhenPresent(record::getPhone)
                .set(TbStaffTrailHisDynamicSqlSupport.roadId).equalToWhenPresent(record::getRoadId)
                .set(TbStaffTrailHisDynamicSqlSupport.organId).equalToWhenPresent(record::getOrganId)
                .set(TbStaffTrailHisDynamicSqlSupport.status).equalToWhenPresent(record::getStatus)
                .set(TbStaffTrailHisDynamicSqlSupport.workLong).equalToWhenPresent(record::getWorkLong)
                .set(TbStaffTrailHisDynamicSqlSupport.frequency).equalToWhenPresent(record::getFrequency)
                .set(TbStaffTrailHisDynamicSqlSupport.inputTime).equalToWhenPresent(record::getInputTime)
                .set(TbStaffTrailHisDynamicSqlSupport.remark).equalToWhenPresent(record::getRemark);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(TbStaffTrailHis record) {
        return UpdateDSL.updateWithMapper(this::update, TbStaffTrailHisDynamicSqlSupport.tbStaffTrailHis)
                .set(TbStaffTrailHisDynamicSqlSupport.name).equalTo(record::getName)
                .set(TbStaffTrailHisDynamicSqlSupport.phone).equalTo(record::getPhone)
                .set(TbStaffTrailHisDynamicSqlSupport.roadId).equalTo(record::getRoadId)
                .set(TbStaffTrailHisDynamicSqlSupport.organId).equalTo(record::getOrganId)
                .set(TbStaffTrailHisDynamicSqlSupport.status).equalTo(record::getStatus)
                .set(TbStaffTrailHisDynamicSqlSupport.workLong).equalTo(record::getWorkLong)
                .set(TbStaffTrailHisDynamicSqlSupport.frequency).equalTo(record::getFrequency)
                .set(TbStaffTrailHisDynamicSqlSupport.inputTime).equalTo(record::getInputTime)
                .set(TbStaffTrailHisDynamicSqlSupport.remark).equalTo(record::getRemark)
                .where(TbStaffTrailHisDynamicSqlSupport.id, isEqualTo(record::getId))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(TbStaffTrailHis record) {
        return UpdateDSL.updateWithMapper(this::update, TbStaffTrailHisDynamicSqlSupport.tbStaffTrailHis)
                .set(TbStaffTrailHisDynamicSqlSupport.name).equalToWhenPresent(record::getName)
                .set(TbStaffTrailHisDynamicSqlSupport.phone).equalToWhenPresent(record::getPhone)
                .set(TbStaffTrailHisDynamicSqlSupport.roadId).equalToWhenPresent(record::getRoadId)
                .set(TbStaffTrailHisDynamicSqlSupport.organId).equalToWhenPresent(record::getOrganId)
                .set(TbStaffTrailHisDynamicSqlSupport.status).equalToWhenPresent(record::getStatus)
                .set(TbStaffTrailHisDynamicSqlSupport.workLong).equalToWhenPresent(record::getWorkLong)
                .set(TbStaffTrailHisDynamicSqlSupport.frequency).equalToWhenPresent(record::getFrequency)
                .set(TbStaffTrailHisDynamicSqlSupport.inputTime).equalToWhenPresent(record::getInputTime)
                .set(TbStaffTrailHisDynamicSqlSupport.remark).equalToWhenPresent(record::getRemark)
                .where(TbStaffTrailHisDynamicSqlSupport.id, isEqualTo(record::getId))
                .build()
                .execute();
    }
}